/**
 *  Copyright (C) 2023 - Fake Inc.
 *
 *  All Rights Reserved.

 */

#include <iostream>
#include "fake_inno_log_cpp.h"

int32_t main() {
  int32_t main_res{0};

  try {
    Fake::init_logger();

    Fake::inno_log(Fake::InnoLogLevel::INNOLOG_LEVEL_DEBUG, __FILE__, __FUNCTION__, __LINE__,
                   "This is a debug message %d", 123);
    const Fake::InnoLogCallback log_cb = [](const int8_t* const src_file, const int8_t* const src_func,
                                            int32_t src_line, int32_t src_lev, const int8_t* const src_msg) {
      const std::string log_file_str{reinterpret_cast<const char*>(src_file)};
      const std::string log_func_str{reinterpret_cast<const char*>(src_func)};
      const std::string log_msg_str{reinterpret_cast<const char*>(src_msg)};
      Fake::inno_log(static_cast<Fake::InnoLogLevel>(src_lev), log_file_str, log_func_str,
                     src_line, log_msg_str);
    };
    Fake::register_callback(log_cb);
    Fake::start_c_module();

  } catch (...) {
    std::cerr << "Exception occurred" << std::endl;
    main_res = 1;  // Exception occurred
  }

  return main_res;  // Single point of exit
}
